/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jhave.client;

import javax.swing.*;
import java.util.*;
import java.awt.*;
import org.jdom.Element;
/**
 *
 * @author Kevin
 */
public class JHAVE_ClickingArea_Factory {

    JPanel returnedPanel;
    Vector components;
    int mode;
    boolean clickingArea;


     /**
     * Finds the correct ComboBox JHAVE_Element and adds it to its proper place in the returnedPanel JPanel and components Vector.
     *
     *@param
     *@param child - Current element.
     *@param returnedPanel - The main JPanel.
     *@param components - Vector that holds added elements.
     *@param mode - Current integer value for mode.
     *@param clickingArea -Boolean stating whether or not a ClickingArea is needed.
     *
     *@return JHAVE_Element.
     */
    public JHAVE_Element get_JHAVE_Element(Element child, JPanel returnedPanel, Vector components, int mode, boolean clickingArea){
        String type = child.getName();
        JHAVE_Abstract_ClickingArea_Element element = null;
        this.returnedPanel = returnedPanel;
        this.components = components;
        this.mode = mode;
        this.clickingArea = clickingArea;


        if(type.equalsIgnoreCase("label_line")){
	    element = new ClickingArea_Label_Line_Element(child, this.returnedPanel, this.components, this.mode, this.clickingArea);
	    element.addElementToPanel();
            this.returnedPanel = element.returnPanel();
            this.components = element.returnComponents();
            this.mode = element.returnMode();
            this.clickingArea = element.returnClickingArea();

        }
	else if(type.equalsIgnoreCase("default_line")){
            element = new ClickingArea_Default_Line_Element(child, this.returnedPanel, this.components, this.mode, this.clickingArea);
	    element.addElementToPanel();
            this.returnedPanel = element.returnPanel();
            this.components = element.returnComponents();
            this.mode = element.returnMode();
            this.clickingArea = element.returnClickingArea();
	}
        else{
            //Throw error stating not a proper type
        }

        return element;

    }

     /**
     * Returns returnedPanel.
     *
     *@return Returns the main JPanel.
     */
    public JPanel returnPanel(){
        return returnedPanel;
    }

     /**
     * Returns the components vector.
     *
     *@return Returns the components vector.
     */
    public Vector returnComponents(){
        return components;
    }

     /**
     * Returns mode.
     *
     *@return Returns mode integer.
     */
    public int returnMode(){
        return mode;
    }

     /**
     * Returns ClickingArea.
     *
     *@return Returns ClickingArea.
     */
    public boolean returnClickingArea(){
        return clickingArea;
    }
}